Skip to main content

FirstCase

FirstCase[{e1,e2,…},pattern] gives the first ei to match pattern, or Missing["NotFound"] if none matching pattern is found. 

FirstCase[{e1,…},pattern->rhs] gives the value of rhs corresponding to the first ei to match pattern.

FirstCase[expr,pattern,default] gives default if no element matching pattern is found.

FirstCase[expr,pattern,default,levelspec] finds only objects that appear on levels specified by levelspec.

FirstCase[pattern] represents an operator form of FirstCase that can be applied to an expression.

Please visit the official Wolfram Language Reference for more details and examples on core symbols.